package com.learn.micro_mall.service.convertor.brand;

import com.learn.micro_mall.domain.entity.brand.BrandEntity;
import com.learn.micro_mall.service.request.brand.BrandDeleteRequest;
import com.learn.micro_mall.service.request.brand.BrandCreateRequest;
import com.learn.micro_mall.service.request.brand.BrandUpdateRequest;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface BrandMapper {

    /**
     * 获取该类自动生成的实现类的实例
     * 接口中的属性都是 public static final 的 方法都是public abstract的
     */
    BrandMapper INSTANCES = Mappers.getMapper(BrandMapper.class);


    @Mappings({
            @Mapping(source = "brandName", target = "brandId.brandName")
    })
    BrandEntity toBrandEntity(BrandCreateRequest request);

    @Mappings({
            @Mapping(source = "brandName", target = "brandId.brandName")
    })
    BrandEntity toBrandEntity(BrandUpdateRequest request);

    @Mappings({
            @Mapping(source = "brandName", target = "brandId.brandName")
    })
    BrandEntity toBrandEntity(BrandDeleteRequest request);

}
